import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';

buttonGradient(text, ontap,
    {double? width,
    double? height,
    double? radius,
    int? flex,
    double? fontSize,
    List<Color>? colors}) {
  var ls = LStyle(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(radius ?? 0),
          gradient: LinearGradient(
            colors:
                colors ?? [const Color(0xFFFF9188), const Color(0xFFFF3072)],
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
          )),
      width: width,
      height: height,
      radius: radius,
      flex: flex,
      alignment: Alignment.center,
      fontWeight: FontWeight.w500,
      fontSize: fontSize ?? 16.sp,
      color: Colors.white);
  return LText(text, lStyle: ls, onTap: ontap);
  // return LContainer(
  //   lStyle: ls,
  //   onTap: ontap,
  //   child: LText(lStyle: ls,),
  // );
}

button(text, ontap,
    {double? width,
    double? height,
    double? radius,
    int? flex,
    double? fontSize,
    List<Color>? colors,
    padding,
    backgroundColor}) {
  var ls = LStyle(
      decoration: BoxDecoration(
          color: backgroundColor,
          borderRadius: BorderRadius.circular(radius ?? 0),
          gradient: backgroundColor == null
              ? LinearGradient(
                  colors: colors ??
                      [
                        const Color(0xFF5EBDEA),
                        const Color(0xffA1F6A0),
                      ])
              : null),
      padding: padding,
      width: width,
      height: height,
      radius: radius,
      flex: flex,
      alignment: Alignment.center,
      fontWeight: FontWeight.w500,
      fontSize: fontSize ?? 16.sp,
      color: Colors.white);
  return LText(text, lStyle: ls, onTap: ontap);
}

buttonDisable(text, ontap,
    {double? width,
    double? height,
    double? radius,
    int? flex,
    double? fontSize,
    List<Color>? colors}) {
  var ls = LStyle(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(radius ?? 0),
          gradient: LinearGradient(
            colors:
                colors ?? [const Color(0xFFFF9188), const Color(0xFFFF3072)],
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
          )),
      width: width,
      height: height,
      radius: radius,
      flex: flex,
      alignment: Alignment.center,
      fontWeight: FontWeight.w500,
      fontSize: fontSize ?? 16.sp,
      color: Colors.white);
  return LText(text, lStyle: ls, onTap: ontap);
}

bottomTabButton(text, img, check, ontap,
    {double? width,
    double? height,
    double? radius,
    int? flex,
    double? fontSize}) {
  var ls = LStyle(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(radius ?? 0),
          gradient: const LinearGradient(
            colors: [Color(0xFFFF9188), Color(0xFFFF3072)],
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
          )),
      width: width,
      height: height,
      radius: radius,
      flex: flex,
      alignment: Alignment.center,
      fontWeight: FontWeight.w500,
      fontSize: fontSize ?? 16.sp,
      color: Colors.white);
  return check
      ? LContainer(
          lStyle: ls,
          child: LImage.easy(img),
        )
      : LText(text, lStyle: ls, onTap: ontap);
}
